<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>抱团</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no,minimal-ui,viewport-fit=cover"/>
    <meta name="keywords" content="抱团">
    <meta name="description" content="抱团">
    <script type="text/javascript" src="js/base.js" charset="UTF-8"></script>
    <!-- <link rel="stylesheet" type="text/css" href="css/theme-chalk/index.css"> -->
    <!-- <link rel="stylesheet" type="text/css" href="css/swiper-bundle.min.css"> -->
    <link rel="stylesheet" type="text/css" href="css/base.css">
    <link rel="stylesheet" type="text/css" href="css/style.css">
    <script type='text/javascript' src="js/jquery.min.js" charset="UTF-8"></script>
    <!-- <script type='text/javascript' src="js/html2canvas.min.js" charset="UTF-8"></script> -->
    <script type="text/javascript" src="js/layer/layer.js" charset="UTF-8"></script>
    <script type="text/javascript" src="js/vue.js" charset="UTF-8"></script>
    <script type="text/javascript" src="js/axios.min.js" charset="UTF-8"></script>
    <!-- <script type='text/javascript' src="js/elementui.min.js" charset="UTF-8"></script> -->
    <!-- <script type='text/javascript' src="js/swiper-bundle.min.js" charset="UTF-8"></script> -->
    <script type='text/javascript' src="../common/js/helper.js" charset="UTF-8"></script>
</head>
<style>
    html,body,#app{height: 100%;overflow: hidden;position: relative;}
</style>
<body>
    <div class="page regist" id="app">
            <div class="logo"></div>
            <div class="des">注册成为达人</div>
            <div class="regBox">
                <div class="item">
                    <input type="text" v-model="mobile" placeholder="请输入手机号">
                </div>
                <div class="item">
                    <input type="text" v-model="verify" placeholder="请输入验证码">
                    <div class="yzm" @click="getVerify"><span v-if="isgeted==false">获取验证码</span><span style="color: #646464;" v-else>{{getTime}}秒</span></div>
                </div>
                <button @click="goregist">提交注册</button>
            </div>
    </div>
    
</body>
<script>
    new Vue({
        el: '#app',
        data () {
            return {
                mobile:'',
                verify:'',
                pid:0,
                isgeted:false,
                getTime:60,
                getTimefun:null,
                allowclick:true,
            }
        },
        mounted () {
            
            var that=this;
            that.pid=getUrlParam("pid")==null?0:getUrlParam("pid");
            console.log(that.pid)
        },
        methods: {
            getVerify:function(){
                var that=this;
                var mobile=that.mobile;
                var checkmobile=/^1(3|4|5|6|7|8|9)\d{9}$/;
                if(that.allowclick==true && that.isgeted==false){
                    layer.closeAll();
                    that.allowclick=false;
                    if(!mobile){
                        layer.msg('请填写手机号');
                        that.allowclick=true;
                        return false;
                    }else if(!checkmobile.test(mobile)){
                        layer.msg('您填写的手机号有误，请重新填写');
                        that.allowclick=true;
                        return false;
                    }
                    that.isgeted=true;
                    clearInterval(that.getTimefun);
                    var time=60;
                    that.getTime=time;
                    that.getTimefun=setInterval(()=>{
                        time--;
                        that.getTime=time;
                        if(time==0){
                            that.isgeted=false;
                            clearInterval(that.getTimefun);
                        }
                    },1000)
                    that.allowclick=true;
                    common_post('verify_code',{
                        "mobile": mobile,
                    }).then(res => {
                        console.log(res)
                        that.setverify=res;
                        that.allowclick=true;
                    })
                }
            },
            goregist:function(){
                var that=this;
                var mobile=that.mobile;
                var checkmobile=/^1(3|4|5|6|7|8|9)\d{9}$/;
                var verify=that.verify;
                layer.closeAll();
                if(!mobile){
                    layer.msg('请填写手机号');
                    that.allowclick=true;
                    return false;
                }else if(!checkmobile.test(mobile)){
                    layer.msg('您填写的手机号有误，请重新填写');
                    that.allowclick=true;
                    return false;
                }
                if(!verify){
                    layer.msg('请填写验证码');
                    that.allowclick=true;
                    return false;
                }
                if(that.pid==0){
                    talent_post('register',{
                        "mobile": mobile,
                        "sms_code": verify,
                        "wx_user_id": getCookie('wx_user_id'),
                    }).then(res => {
                        window.location.href='./registRes.html';
                    })
                }else{
                    talent_post('register',{
                        "mobile": mobile,
                        "sms_code": verify,
                        "parent_id": that.pid,
                        "wx_user_id": getCookie('wx_user_id'),
                    }).then(res => {
                        window.location.href='./registRes.html';
                    })
                }
            },
        }
    });
</script>
</html>